<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <title>Title</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->

    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->

    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->

    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="all-classes-container">
    <div class="row ui-helper-clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>书籍列表————显示所有书籍</small>
                </h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-4 column" style="margin-left: 20px">
                <a class="btn btn-primary" href="${pageContext.request.contextPath}/admin/admingetBooks">显示所有书籍</a>
            </div>
            <div class="col-md-4 column">
                <form class="form-inline" action="${pageContext.request.contextPath}/admin/searchBook" method="post"
                      style="float: right"
                      autocomplete="off">
                    <input type="text" class="form-control" name="bookName" id="asd" required autocomplete="off"
                           placeholder="请输入要查询的书籍或类别"/>
                    <input type="submit" value="查询" class="btn btn-primary"/>
                </form>
            </div>
        </div>
    </div>
    <div class="row ui-helper-clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>书籍名称</th>
                    <th>书籍作者</th>
                    <th>书籍出版社</th>
                    <th>书籍类别</th>
                    <th>发行日期</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="book" items="${books}">
                    <tr>
                        <td>${book.bookName}</td>
                        <td>${book.bookAuthor}</td>
                        <td>${book.bookConcern}</td>
                        <td>${book.bookInfo}</td>
                        <td>${book.bookDate}</td>
                        <td><a class="btn btn-warning"
                               href="${pageContext.request.contextPath}/admin/delete/${book.bookName}">下架</a>
                        </td>
                        <td><a class="btn btn-info"
                               href="${pageContext.request.contextPath}/admin/toUpdate/${book.bookName}">修改</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<c:if test="${pageInfo.pages>=1}">
    <ul class="pagination">
        <li class="page-item">
            <a href="${pageContext.request.contextPath}/admin/admingetBooks?page=${pageInfo.pageNum-1}&size=${pageInfo.pageSize}">
                上一页
            </a>
        </li>

        <li class="page-item">
            <a class="page-link"
               href="${pageContext.request.contextPath}/admin/admingetBooks?page=1&size=${pageInfo.pageSize}">
                首页
            </a>
        </li>
        <c:forEach var="i" begin="2" end="${pageInfo.pages-1}">
            <li class="page-item">
                <a href="${pageContext.request.contextPath}/admin/admingetBooks?page=${i}&size=${pageInfo.pageSize}">
                        ${i}
                </a>
            </li>
        </c:forEach>
        <li class="page-item">
            <a href="${pageContext.request.contextPath}/admin/admingetBooks?page=${pageInfo.pages}&size=${pageInfo.pageSize}">
                尾页
            </a>
        </li>
        <li class="page-item">
            <a href="${pageContext.request.contextPath}/admin/admingetBooks?page=${pageInfo.pageNum+1}&size=${pageInfo.pageSize}">
                下一页
            </a>
        </li>
    </ul>
</c:if>
</body>
</html>
